home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / lib / linux-boot-probes / mounted / 50lilo < prev    next >
Text File  |  2007-07-31  |  2KB  |  125 lines

  1. #!/bin/sh
  2. . /usr/share/os-prober/common.sh
  3. set -e
  4.  
  5. partition="$1"
  6. bootpart="$2"
  7. mpoint="$3"
  8. type="$4"
  9.  
  10. found_item=0
  11.  
  12. title=""
  13. rootdev=""
  14. kernel=""
  15. parameters=""
  16. initrd=""
  17. read_only=""
  18. added_parameters=0
  19. default_rootdev=""
  20. default_kernel=""
  21. default_parameters=""
  22. default_initrd=""
  23. default_read_only=""
  24.  
  25. dequote () {
  26.     item="${1%\"}"
  27.     echo "${item#\"}"
  28. }
  29.  
  30. addparams () {
  31.     # Any parameters we find replace the default parameters, but
  32.     # otherwise append.
  33.     if [ "$added_parameters" = 0 ]; then
  34.         parameters="$1"
  35.         added_parameters=1
  36.     else
  37.         parameters="${parameters:+$parameters }$1"
  38.     fi
  39. }
  40.  
  41. recordstanza () {
  42.     if [ -n "$kernel" ] && [ -n "$title" ]; then
  43.         if [ -e "$mpoint/$kernel" ] && [ -e "$mpoint/$initrd" ]; then
  44.             if [ "$read_only" ]; then
  45.                 parameters="ro $parameters"
  46.             fi
  47.             if [ "$rootdev" ]; then
  48.                 parameters="root=$rootdev $parameters"
  49.             fi
  50.             parameters=${parameters% }
  51.             result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters"
  52.             found_item=1
  53.         else
  54.             debug "cannot find $kernel or $initrd, not recording"
  55.         fi
  56.         title=""
  57.         rootdev="$default_rootdev"
  58.         kernel="$default_kernel"
  59.         parameters="$default_parameters"
  60.         initrd="$default_initrd"
  61.         read_only="$default_read_only"
  62.         added_parameters=0
  63.     else
  64.         # Everything before set default values.
  65.         default_rootdev="$rootdev"
  66.         default_kernel="$kernel"
  67.         default_parameters="$parameters"
  68.         default_initrd="$initrd"
  69.         default_read_only="$read_only"
  70.     fi
  71. }
  72.  
  73. parse_lilo_conf () {
  74.     mpoint="$1"
  75.     rootpart="$2"
  76.     bootpart="$3"
  77.     IFS="     ="
  78.     while read line; do
  79.         debug "parsing: $line"
  80.         set -- $line
  81.         case $1 in
  82.             root)
  83.                 rootdev=$(dequote "$2")
  84.             ;;
  85.             image)
  86.                 recordstanza
  87.                 # Dereference if symbolic link
  88.                 kernel=$(readlink -f $(dequote "$2"))
  89.             ;;
  90.             append)
  91.                 addparams "$(dequote "${line#append=}")"
  92.             ;;
  93.             initrd)
  94.                 # Dereference if symbolic link
  95.                 initrd=$(readlink -f $(dequote "$2"))
  96.                 ;;
  97.             label)
  98.                 shift 1
  99.                 title=$(dequote "$*" | sed -e 's/:/ /g')
  100.             ;;
  101.             other)
  102.                 recordstanza
  103.             ;;
  104.             read-only)
  105.                 read_only=1
  106.             ;;
  107.             vga)
  108.                 addparams "$line"
  109.             ;;
  110.         esac
  111.     done
  112.     recordstanza
  113. }
  114.  
  115. if [ -e "$mpoint/etc/lilo.conf" ]; then
  116.     debug "parsing lilo.conf"
  117.     parse_lilo_conf "$mpoint" "$partition" "$bootpart" < "$mpoint/etc/lilo.conf"
  118. fi
  119.  
  120. if [ "$found_item" = 0 ]; then
  121.     exit 1
  122. else
  123.     exit 0
  124. fi
  125.